﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using global::TerhelesEloszto.Engine;

namespace Presentation
{
	public partial class CreateSkill : System.Web.UI.Page
	{
		protected global::TerhelesEloszto.Engine.IEngine engine = global::TerhelesEloszto.Engine.Engine.Instance();
		protected void Page_Load( object sender, EventArgs e )
		{
			String visitorName = User.Identity.Name;
			if( !engine.IsAdmin( visitorName ) )
			{
				if( engine.IsTeacher( visitorName ) )
				{
					Response.Redirect( "~/Teacher/TeacherProblem.aspx" );
				}
				else
				{
					Response.Redirect( "~/Problem.aspx" );
				}

			}
		}

		protected void CreateSkillBtn_Click( object sender, EventArgs e )
		{
			try
			{
				engine.CreateSkill( SkillBox.Text );
				Response.Redirect( "~/Admin/Skills.aspx?msg=1" );
			}
			catch( EngineException ex )
			{
				Response.Redirect( "~/Admin/Skills.aspx?msg=0" );
			}
		}
	}
}